// 转换签署进度
const toActionType = (num) => {
       switch(num) {
              case 0: return '已签署';
              case 1: return '已审阅';
              case 2: return '未签署';
              case 3: return '未审阅';
              case 5: return '抄送';
       }
       return num;
}

// 转换毫秒数为日期
const toDate = (num) => {
       // 如果没有参数则为永久合同
       if(!num) return '永久';

       let d = new Date(num);
       let year = d.getFullYear();
       let month = d.getMonth() + 1;
       let day = d.getDate();

       return `${year}-${month}-${day}`;
}

// 转换百分比为小数
const toDecimals = (percent) => {
       return percent.substring(0, percent.length - 1) / 100;
}

// 转换小数为百分比
const toPercent = (decimals) => {
       return decimals * 100 + '%';
}

module.exports = {
       toActionType: toActionType,
       toDate: toDate,
       toDecimals: toDecimals,
       toPercent: toPercent
}
